/*
 *                        .::::.
 *                      .::::::::.
 *                     :::::::::::
 *                  ..:::::::::::'
 *               '::::::::::::'
 *                 .::::::::::
 *            '::::::::::::::..
 *                 ..::::::::::::.
 *               ``::::::::::::::::
 *                ::::``:::::::::'        .:::.
 *               ::::'   ':::::'       .::::::::.
 *             .::::'      ::::     .:::::::'::::.
 *            .:::'       :::::  .:::::::::' ':::::.
 *           .::'        :::::.:::::::::'      ':::::.
 *          .::'         ::::::::::::::'         ``::::.
 *      ...:::           ::::::::::::'              ``::.
 *     ````':.          ':::::::::'                  ::::..
 *                        '.:::::'                    ':'````..
 *
 * @Author: ls
 * @Date: 2021-03-11 13:52:33
 * @LastEditTime: 2021-03-12 17:18:55
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \creator_i18n\assets\Script\Helloworld.ts
 */

import { i18nMgr } from './i18n/i18nMgr';
import { i18nLabel } from './i18n/i18nLabel';
import { i18nConstant } from './i18n/i18nConstant';

const { ccclass, property } = cc._decorator;

@ccclass
export class Helloworld extends cc.Component {
    @property({ visible: false })
    private nowLanguage: i18nConstant = i18nConstant.zh;

    @property({ type: cc.Enum(i18nConstant), displayName: '语言' })
    get language() {
        return this.nowLanguage;
    }
    set language(value: i18nConstant) {
        this.nowLanguage = value;
        i18nMgr.setLanguage(i18nConstant[value]);
    }

    onLoad() {
        i18nMgr.setLanguage(i18nConstant[this.nowLanguage]);
    }

    start() {
        // this.node.getChildByName("label2").getComponent(i18nLabel).init("love_msg", ["a1", "b2"]);
    }

    setEn() {
        i18nMgr.setLanguage(i18nConstant[i18nConstant.en]);
    }

    setZh() {
        i18nMgr.setLanguage(i18nConstant[i18nConstant.zh]);
    }
}
